package com.prs.crm.dao.ca.work.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;


import com.prs.crm.dao.ca.work.ArticleTypesDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.ca.work.ArticleTypes;
import com.prs.crm.domain.oa.ArticleType;

public class ArticleTypesDaoImpl extends BaseDaoImpl<ArticleTypes> implements
		ArticleTypesDao {

	@Override
	public List<ArticleTypes> getAllArticleTypes() {
		Criteria criteria = this.getSession().createCriteria(ArticleTypes.class);
		List<ArticleTypes> r= criteria.list();
		if(r.size()!=0){
			return r;
		}else{
			return null;
		}
	}

	@Override
	public ArticleTypes getArticleTypesByName(final String name) {
		Criteria criteria = this.getSession().createCriteria(ArticleTypes.class);
		criteria.add(Restrictions.eq("ca_at_typeName", name));
		List r= criteria.list();
		if(r.size()!=0){
			return (ArticleTypes) r.get(0);
		}else{
			return null;
		}
	}

//	@Override
//	public void saveOrArticleType(ArticleType articleType) {
//		this.getHibernateTemplate().saveOrUpdate(articleType);
//	}
}
